﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WordAnalyzer : MonoBehaviour
{
    public static WordAnalyzer Instance;

    public TextAsset positiveWords;
    public TextAsset negativeWords;

    // Start is called before the first frame update
    void Awake()
    {
        Instance = this;
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public bool CheckPositive(string msg)
    {
        return CheckWord(positiveWords.text, msg);
    }
    
    public bool CheckNegative(string msg)
    {
        return CheckWord(negativeWords.text, msg);
    }

    public bool CheckWord(string wordList, string msg)
    {
        foreach (var matchWord in wordList.Split('\n'))
        {
           
            if (msg.Contains(matchWord.ToUpper().Trim()) && matchWord.ToUpper().Trim() != string.Empty)
            {
                return true;
            }
        }

        return false;

    }
}
